<?php $style_th = 'style="background-color:#CCCCCC"' ;?>
<?php $style_td = 'style="border:solid 1px #000"' ;?>
<?php $style_is_code = 'style="color:#FF0000"' ;?>
<?php $style_h2= 'style="width:100%;text-align:center;font-weight:bold;font-size:24px"';?>
<?php $style_description= ' style="width:100%;text-align:center;font-style:italic" ';?>

<div <?php echo $style_h2 ?>>BÁO CÁO CHI TIẾT NHẬP XUẤT TỒN</div>
<div <?php echo $style_description ?>>Từ ngày: <?php echo $this->from_time?>. Đến ngày: <?php echo $this->to_time?></div>
<br/>
<table cellpadding="4" cellspacing="0" border='1' style="width:100%; border-collapse:collapse">
	<thead>			
		<tr>
			<th rowspan='2' <?php echo $style_th ?>>STT</th>
			<th rowspan='2' <?php echo $style_th ?>>Mã thành phẩm</th>
			<th rowspan='2' <?php echo $style_th ?>>Tên thành phẩm</th>
			<th rowspan='2' <?php echo $style_th ?>>Tồn đầu kỳ</th>
			<th colspan='<?php echo $this->in_count; ?>' <?php echo $style_th ?>>
				Nhập trong kỳ
			</th>
			<th colspan='<?php echo $this->out_count;?>' <?php echo $style_th ?>>
				Xuất trong kỳ
			</th>
			<th rowspan='2' <?php echo $style_th ?>>Tồn cuối kỳ</th>
		</tr>
		<tr>
			<?php foreach ($this->reasons as $reason){?>
			<th <?php echo $style_th ?>><?php echo $reason->reason_code?></th>
			<?php }?>
		</tr>
	</thead>
	<tbody>
		<?php if(count($this->paginator)>0){$no=1; foreach ($this->paginator as $row){?>
		<tr>
			<td align="center"><?php echo $no++ ;?></td>
			<td >
				<?php echo $row->inbound_detail_product_code?>
			</td>
			<td >
				<?php echo  $row->m_Array['product_name'] ?>
			</td>
			<td class="right">
				<?php $first=$row->m_Array['first'];echo $first?>
			</td>			
			<?php 
			$last=$first;
			foreach ($this->reasons as $reason)
			{
				$quantity=$row->m_Array['reason_'.$reason->reason_code];
				$last=$last+($reason->reason_inbound_type==0?1:-1)*$quantity;
			?>
			<td class="right" style="background-color:<?php echo $reason->reason_inbound_type==0?"#dce6f1":"#ebf1de"?>">
				<?php echo $quantity?>
			</td>
			<?php 
			}
			?>
			<td class="right">
				<?php echo $last?>
			</td>
		</tr>
		<?php }}?>
	</tbody>
</table>